<!DOCTYPE html>
<html>
<head>
    <title>优惠券编辑</title>
    <#include "/header.html">
    <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.0.0.min.js"></script>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<div  class="panel panel-default" id="rrapp">
    <div class="panel-heading" >优惠券</div>
    <form class="form-horizontal">

        <div class="form-group">
            <div class="col-sm-2 control-label" style="color: red;">公众号标识</div>
            <div class="col-sm-10">
                <input class="form-control" list="editGzhCodes" placeholder="公众号标识" id="gzhCodes">
                <datalist id="editGzhCodes" style="line-height: 10px">

                </datalist>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">优惠金额1</div>
            <div class="col-sm-10">
                <input type="text" class="form-control"  id="priceOne" name="priceOne" placeholder="优惠金额1" v-model="couponInfo.priceOne"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">优惠金额2</div>
            <div class="col-sm-10">
                <input type="text" class="form-control"  id="priceTwo" name="priceTwo" placeholder="优惠金额2" v-model="couponInfo.priceTwo"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">优惠金额3</div>
            <div class="col-sm-10">
                <input type="text" class="form-control"  id="priceThree" name="priceThree" placeholder="优惠金额3" v-model="couponInfo.priceThree"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">优惠金额4</div>
            <div class="col-sm-10">
                <input type="text" class="form-control"  id="priceFour" name="priceFour" placeholder="优惠金额4" v-model="couponInfo.priceFour"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label" >是否可用</div>
            <div class="col-sm-10">
                <label class="radio-inline">
                    <input type="radio" name="enabled" value="1" v-model="couponInfo.enabled"/> 可用
                </label>
                <label class="radio-inline">
                    <input type="radio" name="enabled" value="0"  v-model="couponInfo.enabled"/> 不可用
                </label>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">有效开始时间</div>
            <div class="col-sm-10">
                <input type="datetime-local" class="form-control"  id="startTime" name="startTime" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">有效结束时间</div>
            <div class="col-sm-10">
                <input type="datetime-local" class="form-control"  id="endTime" name="endTime"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary" @click="updateInfo" value="保存"/>
            <input onclick='window.close();' type="button" value="返回" class="rrapp-but" style="background-color: #f0ad4e;border-color: #f0ad4e;color: #fff"/>
        </div>
    </form>
</div>
<script src="${request.contextPath}/statics/js/modules/sys/coupon.js?_${.now?long}"></script>
<script>

    $(function () {
        var url = location.search;
        var couponId = url.split("=")[1];
        if(couponId!=0){
           loadData(couponId);
        }
        $.ajax({
            type: "POST",
            async:false,
            url: baseURL + 'sys/buserinfo/getUserGzhList',
            contentType: "application/json",
            success: function(r){
                if(r.code==0){
                    for(var i=0;i<r.userGzhList.length;i++){
                        $("#editGzhCodes").append(
                            "<option value=" + r.userGzhList[i].gzhCode +">"+ r.userGzhList[i].gzhName+"</option>");
                    }
                }
            }
        });
    })
    function loadData(e) {
        $.ajax({
            type: "POST",
            url: baseURL + "sys/coupon/couponById/",
            contentType: "application/json",
            data: JSON.stringify(e),
            success: function(r){
                console.log(r);
                vm.couponInfo = r.coupon;
                $("#gzhCodes").val(vm.couponInfo.gzhCode);
                $("#startTime").val(vm.couponInfo.startTime.replace(/ /ig, 'T'));
                $("#endTime").val(vm.couponInfo.endTime.replace(/ /ig, 'T'));
            }
        });
    }

</script>
</body>
</html>